//
//  LearnWordViewController.m
//  HotWord
//
//  Created by ZHONG YUE on 11-8-24.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "LearnWordViewController.h"
#import "MainMenuViewController.h"
#import "WordView.h"
#import "TranslateView.h"
#import "CacheData.h"
#import "Word.h"
#import "HotWordAppDelegate.h"
#import "WordCommonView.h"

@implementation LearnWordViewController
@synthesize paranyScrollView;
@synthesize synonyScrollView;
@synthesize antonyScrollView;
@synthesize TopBackImgView;
@synthesize CoverImgView;
@synthesize SameImgView;
@synthesize AntonymImgView;
@synthesize SynonymImgView;
@synthesize GuessBtn;
@synthesize SameBtn;
@synthesize AntonymBtn;
@synthesize SynonymBtn;
@synthesize SameShadowImgView;
@synthesize AntonymShadowImgView;
@synthesize SynonymShadowImgView;
@synthesize ShowMoreBtn;
@synthesize ReturnBtn;
@synthesize wordIndexLabel;
@synthesize leftForwordImgView;
@synthesize rightForwordImgView;
@synthesize sameLabel;
@synthesize antonyLabel;
@synthesize synonyLabel;
@synthesize sameLeftImgview;
@synthesize sameRightImgView;
@synthesize antonyLeftImgView;
@synthesize antonyRightImgView;
@synthesize synonyLeftImgView;
@synthesize synonyRightImgView;
@synthesize _guessBtnTouchCount;
@synthesize CoverImageViewShadow;
@synthesize currentChangedWordIndex,currentAntonymWordIndex,currentParanymWordIndex,currentSynonymWordIndex;
@synthesize transGoLeft,transGoRight;
//@synthesize SameLabel;
//@synthesize AntonymLabel;
//@synthesize SynonymLabel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        //[self setMemeberKit];
        
        //初始化猜单词按钮得点击次数
        _guessBtnTouchCount = 0;
    }
    return self;
}


//设置所有成员控件得属性和初始化指示变量
- (void)setMemeberKit
{
    
    //初始化遮住单词
    [self.view addSubview:self.TopBackImgView];
    
    [self.view addSubview:CoverImgView];
    
    [self.view addSubview:CoverImageViewShadow];
    
    
    [self LoadPrepareThreeImgView];
  // self.ShowMoreBtn.hidden=NO;
   // self.ShowMoreBtn.userInteractionEnabled=YES;
    [self.view addSubview:self.ShowMoreBtn];
//    self.ShowMoreBtn.hidden=NO;
//    self.ShowMoreBtn.userInteractionEnabled=YES;
    
    [self.view addSubview:GuessBtn];

    
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    // 添加支持单词侧滑
    
    
    self.CoverImgView.frame=CGRectMake(0, -161, 320, 88);
    self.TopBackImgView.frame=CGRectMake(11, -187, 297, 156);
    self.GuessBtn.frame=CGRectMake(137, -50, 44, 44);
    self.wordIndexLabel.frame=CGRectMake(93, -187, 134, 28);
    self.CoverImageViewShadow.frame=CGRectMake(0, -74, 320, 53);
    self.leftForwordImgView.frame=CGRectMake(0, -129, 23, 23);
    self.rightForwordImgView.frame=CGRectMake(297, -129, 23, 23);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationRepeatAutoreverses:NO];
    
    self.CoverImgView.frame=CGRectMake(0, 39, 320, 88);
    self.TopBackImgView.frame=CGRectMake(11, 13, 297, 156);
    self.GuessBtn.frame=CGRectMake(137, 150, 44, 44);
    self.wordIndexLabel.frame=CGRectMake(93, 13, 134, 28);
    self.leftForwordImgView.frame=CGRectMake(0, 71, 23, 23);
    self.rightForwordImgView.frame=CGRectMake(297, 71, 23, 23);
    self.CoverImageViewShadow.frame=CGRectMake(0, 126, 320, 53);
    // [UIView setAnimationDidStopSelector:(newInit)];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];


    
    [CoverImgView setUserInteractionEnabled:YES];
    wordScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(23, 0, 274, 85)];
    wordScrollView.pagingEnabled = YES;
    wordScrollView.delegate = self;
    wordScrollView.showsHorizontalScrollIndicator = NO;
    [CoverImgView addSubview:wordScrollView];
    
    NSInteger beginIndex = [[CacheData sharedData].selectedLetter.learnIndex intValue];
    NSInteger wordsCount = [[CacheData sharedData].selectedLetter.words count];
    
    
    for (int i = 0 ; i < wordsCount; i++) {
        Word *aword = [[CacheData sharedData].selectedLetter.words objectAtIndex:i];
        WordView *wordView = [[[NSBundle mainBundle] loadNibNamed:@"WordView" owner:self options:nil] objectAtIndex:0];
        [wordView setWord:aword];
        wordView.frame = CGRectMake(274 * i, 0, 274, 85);
        [wordView setUserInteractionEnabled:NO];
        [wordScrollView addSubview:wordView];
    }
     wordScrollView.contentOffset=CGPointMake(274 * beginIndex, 85);
    wordScrollView.contentSize = CGSizeMake(274 * wordsCount, 85);
   
    
    [TopBackImgView setUserInteractionEnabled:YES];
    word = [[[CacheData sharedData].selectedLetter.words objectAtIndex:beginIndex] retain];
    translateScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(15, 55, 255, 60)];
    translateScrollView.pagingEnabled = YES;
    translateScrollView.delegate=self;
    translateScrollView.showsHorizontalScrollIndicator = NO;
    translateScrollView.backgroundColor = [UIColor clearColor];
    [TopBackImgView addSubview:translateScrollView];
    
    for (int i = 0; i < [word.tanses count]; i ++) {
        TranslateView *translateView = [[[NSBundle mainBundle] loadNibNamed:@"TranslateView" owner:self options:nil] objectAtIndex:0];
        [translateView setTranslate:[word.tanses objectAtIndex:i]];
        translateView.frame = CGRectMake(255 * i, 0, 255, 60);
        [translateView setUserInteractionEnabled:YES];
        [translateScrollView addSubview:translateView];
    }
    translateScrollView.contentSize = CGSizeMake(255 * [word.tanses count], 60);
    
    //2011.09.05 update
    currentChangedWordIndex = wordScrollView.contentOffset.x/274 + 1;
    self.wordIndexLabel.text = [NSString stringWithFormat:@"%d/%d",currentChangedWordIndex,wordsCount];
    

    
    
    if (currentChangedWordIndex > 1 && currentChangedWordIndex < wordsCount) {
        self.leftForwordImgView.alpha = 1.0f;
        self.rightForwordImgView.alpha = 1.0f;
    }else if(currentChangedWordIndex == 1 && wordsCount > 1){
//        self.leftForwordImgView.hidden = YES;
//        self.rightForwordImgView.hidden = NO;
        
        self.leftForwordImgView.alpha = 0.0f;
        self.rightForwordImgView.alpha = 1.0f;
    }else if(currentChangedWordIndex == wordsCount && wordsCount > 1){
//        self.leftForwordImgView.hidden = NO;        
//        self.rightForwordImgView.hidden = YES;
        self.leftForwordImgView.alpha = 1.0f;
        self.rightForwordImgView.alpha = 0.0f;
    }
    self.sameLabel.alpha= 0.0f;
    self.sameLeftImgview.alpha = 0.0f;
    self.sameRightImgView.alpha = 0.0f;
    self.antonyLabel.alpha = 0.0f;
    self.antonyLeftImgView.alpha = 0.0f;
    self.antonyRightImgView.alpha = 0.0f;
    self.synonyLabel.alpha = 0.0f;
    self.synonyLeftImgView.alpha = 0.0f;
    self.synonyRightImgView.alpha = 0.0f;
    
    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    
    //[[appDelegate.MainToolBar viewWithTag:66]removeFromSuperview];
    UIButton *showBtn=[[UIButton alloc]init];
    UIButton *hideBtn=[[UIButton alloc]init];
    showBtn.frame=CGRectMake(135, 20, 50, 50);
    hideBtn.frame=CGRectMake(135, 20, 50, 50);
    showBtn.tag=77;
    hideBtn.tag=88;
    [showBtn addTarget:self action:@selector(ShowThreeImgView) forControlEvents:UIControlEventTouchUpInside];
    [showBtn setImage:[UIImage imageNamed:@"pullout.png"] forState:UIControlStateNormal];
    [showBtn setImage:[UIImage imageNamed:@"pullout.png"] forState:UIControlStateHighlighted];
    [showBtn setBackgroundImage: [UIImage imageNamed:@"tap_light.png"] forState:UIControlStateHighlighted];
    
    [hideBtn addTarget:self action:@selector(HiddenThreeImgView) forControlEvents:UIControlEventTouchUpInside];
    [hideBtn setImage:[UIImage imageNamed:@"pullback.png"] forState:UIControlStateNormal];
    [hideBtn setImage:[UIImage imageNamed:@"pullback.png"] forState:UIControlStateHighlighted];
    [hideBtn setBackgroundImage: [UIImage imageNamed:@"tap_light.png"] forState:UIControlStateHighlighted];
    
    [appDelegate.MainToolBar addSubview:hideBtn];
    [appDelegate.MainToolBar viewWithTag:88].alpha=0.0f;
    
    [appDelegate.MainToolBar addSubview:showBtn];
    Time_Count=0.0f;
    Clock_Count=0.0f;
}

- (void)viewDidUnload
{
    [self setTopBackImgView:nil];
    [self setCoverImgView:nil];
    [self setSameImgView:nil];
    [self setAntonymImgView:nil];
    [self setSynonymImgView:nil];
    [self setGuessBtn:nil];
    [self setSameBtn:nil];
    [self setAntonymBtn:nil];
    [self setSynonymBtn:nil];
    [self setSameShadowImgView:nil];
    [self setAntonymShadowImgView:nil];
    [self setSynonymShadowImgView:nil];
    [self setShowMoreBtn:nil];
    [self setReturnBtn:nil];
    [self setCoverImageViewShadow:nil];
    [self setWordIndexLabel:nil];
    [self setLeftForwordImgView:nil];
    [self setRightForwordImgView:nil];
    [self setSameLabel:nil];
    [self setAntonyLabel:nil];
    [self setSynonyLabel:nil];
    [self setSameLeftImgview:nil];
    [self setSameRightImgView:nil];
    [self setAntonyLeftImgView:nil];
    [self setAntonyRightImgView:nil];
    [self setSynonyLeftImgView:nil];
    [self setSynonyRightImgView:nil];
    [self setParanyScrollView:nil];
    [self setSynonyScrollView:nil];
    [self setAntonyScrollView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView; 
{
    if (scrollView == wordScrollView) {
        
        // NSLog(@"current offset: %f", scrollView.contentOffset.x);
        NSInteger currentWordIndex = scrollView.contentOffset.x/274;
        
       
        //[CacheData sharedData].selectedLetter.learnIndex=(NSNumber *)currentWordIndex;
        
        //wenbin gengxin
        
        //// NSLog(@"%@",currentWordIndex);
        if (currentWordIndex != [[CacheData sharedData].selectedLetter.learnIndex intValue]) {
            
            word = [[[CacheData sharedData] getWordByIndex:currentWordIndex] retain];
            
            for (UIView *view in [translateScrollView subviews]) {
                [view removeFromSuperview];
            }
            translateScrollView.pagingEnabled = YES;
            [TopBackImgView addSubview:translateScrollView];
            
            
            for (int i = 0; i < [word.tanses count]; i ++) {
                TranslateView *translateView = [[[NSBundle mainBundle] loadNibNamed:@"TranslateView" owner:self options:nil] objectAtIndex:0];
                [translateView setTranslate:[word.tanses objectAtIndex:i]];
                translateView.frame = CGRectMake(255 * i, 0, 255, 60);
                [translateScrollView addSubview:translateView];
                translateView.alpha = 0;
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationDelay:0.5];
                [UIView setAnimationDuration:0.1];
                translateView.alpha = 1;
                [UIView commitAnimations];
            }
            translateScrollView.contentSize = CGSizeMake(255 * [word.tanses count], 60);
            
            
            //2011.09.05 update
            NSInteger wordsCount = [[CacheData sharedData].selectedLetter.words count];
            currentChangedWordIndex = scrollView.contentOffset.x/274 + 1;
           // [CacheData sharedData].selectedLetter.learnIndex=[NSNumber numberWithInt:currentChangedWordIndex];
            self.wordIndexLabel.text = [NSString stringWithFormat:@"%d/%d",currentChangedWordIndex,wordsCount];
            
            if (currentChangedWordIndex > 1 && currentChangedWordIndex < wordsCount) {
                
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
             
                self.leftForwordImgView.alpha=1.0f;
                self.rightForwordImgView.alpha =1.0f;
                [UIView commitAnimations];
                
                
                
                
                
            }else if(currentChangedWordIndex == 1 && wordsCount > 1){
//                self.leftForwordImgView.hidden = YES;
//                self.rightForwordImgView.hidden = NO;
                
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
                
                self.leftForwordImgView.alpha=0.0f;
                self.rightForwordImgView.alpha =1.0f;
                [UIView commitAnimations];
                
                
                
                
            }else if(currentChangedWordIndex == wordsCount && wordsCount > 1){
//                self.leftForwordImgView.hidden = NO;
//                self.rightForwordImgView.hidden = YES;
                
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
                
                self.leftForwordImgView.alpha=1.0f;
                self.rightForwordImgView.alpha =0.0f;
                [UIView commitAnimations];
                
                
            }
            
            [self HiddenThreeImgView];
            [self CoverUpToShowWord];
            _guessBtnState = YES;
            
        } 
    }else if ( scrollView == paranyScrollView){
        
        //2011.09.09 update
        NSInteger wordsCount = [word.paranyms count];
        currentParanymWordIndex = scrollView.contentOffset.x/195 + 1;
        
        if (currentParanymWordIndex > 1 && currentParanymWordIndex < wordsCount) {
        
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.sameLeftImgview.alpha = 1.0f;
            self.sameRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
            
            
        }else if(currentParanymWordIndex == 1 && wordsCount > 1){
//            self.sameLeftImgview.hidden = YES;
//            self.sameRightImgView.hidden = NO;
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.sameLeftImgview.alpha = 0.0f;
            self.sameRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
            
        }else if(currentParanymWordIndex == wordsCount && wordsCount > 1){
//            self.sameLeftImgview.hidden = NO;
//            self.sameRightImgView.hidden = YES;
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.sameLeftImgview.alpha = 1.0f;
            self.sameRightImgView.alpha = 0.0f;
            [UIView commitAnimations];
            
        }
    }else if (scrollView == antonyScrollView){
        //2011.09.09 update
        NSInteger wordsCount = [word.antonyms count];
        currentAntonymWordIndex = scrollView.contentOffset.x/195 + 1;
        
        if (currentAntonymWordIndex > 1 && currentAntonymWordIndex < wordsCount) {
         
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.antonyLeftImgView.alpha = 1.0f;
            self.antonyRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
            
            
        }else if(currentAntonymWordIndex == 1 && wordsCount > 1){
//            self.antonyLeftImgView.hidden = YES;
//            self.antonyRightImgView.hidden = NO;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.antonyLeftImgView.alpha = 0.0f;
            self.antonyRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
        }else if(currentAntonymWordIndex == wordsCount && wordsCount > 1){
//            self.antonyLeftImgView.hidden = NO;
//            self.antonyRightImgView.hidden = YES;
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.antonyLeftImgView.alpha = 1.0f;
            self.antonyRightImgView.alpha = 0.0f;
            [UIView commitAnimations];
            
        }
    }else if (scrollView == synonyScrollView){
        //1.09.09 update
        NSInteger wordsCount = [word.synonyms count];
        currentSynonymWordIndex = scrollView.contentOffset.x/195 + 1;
        
        if (currentSynonymWordIndex > 1 && currentSynonymWordIndex < wordsCount) {
        
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.synonyLeftImgView.alpha = 1.0f;
            self.synonyRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
            
        }else if(currentSynonymWordIndex == 1 && wordsCount > 1){
//            self.synonyLeftImgView.hidden = YES;
//            self.synonyRightImgView.hidden = NO;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.synonyLeftImgView.alpha = 0.0f;
            self.synonyRightImgView.alpha = 1.0f;
            [UIView commitAnimations];
            
            
        }else if(currentSynonymWordIndex == wordsCount && wordsCount > 1){
//            self.synonyLeftImgView.hidden = NO;
//            self.synonyRightImgView.hidden = YES;
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.synonyLeftImgView.alpha = 1.0f;
            self.synonyRightImgView.alpha = 0.0f;
            [UIView commitAnimations];
            
        }
        
        
        
        
    }
    else if (scrollView == translateScrollView){
        //2011.09.09 update
        NSInteger wordsCount = [word.tanses count];
        
       int currentIndex = scrollView.contentOffset.x/195 + 1;
        
        if (currentIndex > 1 && currentIndex < wordsCount) {
            
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.transGoLeft.alpha = 1.0f;
            self.transGoRight.alpha = 1.0f;
            [UIView commitAnimations];
            
            
        }else if(currentIndex == 1 && wordsCount > 1){
            //            self.synonyLeftImgView.hidden = YES;
            //            self.synonyRightImgView.hidden = NO;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.transGoLeft.alpha = 0.0f;
            self.transGoRight.alpha = 1.0f;
            [UIView commitAnimations];
            
            
        }else if(currentIndex == wordsCount && wordsCount > 1){
            //            self.synonyLeftImgView.hidden = NO;
            //            self.synonyRightImgView.hidden = YES;
            
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationDuration:0.4f];
            
            self.transGoLeft.alpha = 1.0f;
            self.transGoRight.alpha = 0.0f;
            [UIView commitAnimations];
            
        }
        
        
        
        
    }
    
    
    
    
}
//view是否应该渐变显示 1：渐变显示 2：渐变隐藏
- (void)viewShouldEasyInOut:(UIView *)view withType:(NSInteger)type
{
    
    switch (type) {
        case 1:
            view.alpha = 0;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDuration:0.5];
            view.alpha = 1;
            [UIView commitAnimations];
            break;
        case 2:
            view.alpha = 1;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDuration:0.5];
            view.alpha = 0;
            [UIView commitAnimations];
            break;
        case 3:
            view.hidden = YES;
            break;
        case 4:
            view.hidden = NO;
            break;
            
        default:
            break;
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [TopBackImgView release];
    [CoverImgView release];
    [SameImgView release];
    [AntonymImgView release];
    [SynonymImgView release];
    [GuessBtn release];
    [SameBtn release];
    [AntonymBtn release];
    [SynonymBtn release];
    [SameShadowImgView release];
    [AntonymShadowImgView release];
    [SynonymShadowImgView release];
    [ShowMoreBtn release];
    [ReturnBtn release];
    [wordScrollView release];
    [translateScrollView release];
   // [synonymsLabel release];
    //[paranymsLabel release];
    //[antonymsLabel release];
    [CoverImageViewShadow release];
    [wordIndexLabel release];
    [leftForwordImgView release];
    [rightForwordImgView release];
    [sameLabel release];
    [antonyLabel release];
    [synonyLabel release];
    [sameLeftImgview release];
    [sameRightImgView release];
    [antonyLeftImgView release];
    [antonyRightImgView release];
    [synonyLeftImgView release];
    [synonyRightImgView release];
    [paranyScrollView release];
    [synonyScrollView release];
    [antonyScrollView release];
    [super dealloc];
}
- (IBAction)GuessWordAnimation:(id)sender {
    //判断猜单词按钮得点击状态和点击次数，来确定响应动作
    _guessBtnTouchCount++;
    GuessBtn.enabled=NO;

    if (_guessBtnTouchCount == 1 && _guessBtnState == NO ) {
        [self CoverDownToHiddenWord];
        [self showTransSign];
        //9.15 gengxin
//        NSInteger wordsCount = [word.tanses count];
//        
//        int currentIndex = translateScrollView.contentOffset.x/195 + 1;
//        
//        if (currentIndex > 1 && currentIndex < wordsCount) {
//            
//            
//            [UIView beginAnimations:nil context:nil];
//            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//            [UIView setAnimationDelegate:self];
//            [UIView setAnimationDuration:0.4f];
//            
//            self.transGoLeft.alpha = 1.0f;
//            self.transGoRight.alpha = 1.0f;
//            [UIView commitAnimations];
//            
//            
//        }else if(currentIndex == 1 && wordsCount > 1){
//            //            self.synonyLeftImgView.hidden = YES;
//            //            self.synonyRightImgView.hidden = NO;
//            [UIView beginAnimations:nil context:nil];
//            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//            [UIView setAnimationDelegate:self];
//            [UIView setAnimationDuration:0.4f];
//            
//            self.transGoLeft.alpha = 0.0f;
//            self.transGoRight.alpha = 1.0f;
//            [UIView commitAnimations];
//            
//            
//        }else if(currentIndex == wordsCount && wordsCount > 1){
//            //            self.synonyLeftImgView.hidden = NO;
//            //            self.synonyRightImgView.hidden = YES;
//            
//            [UIView beginAnimations:nil context:nil];
//            [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//            [UIView setAnimationDelegate:self];
//            [UIView setAnimationDuration:0.4f];
//            
//            self.transGoLeft.alpha = 1.0f;
//            self.transGoRight.alpha = 0.0f;
//            [UIView commitAnimations];
//            
//        }

        
      //gengxin jieshu  
        
        
        
        
        
        
        
        
        if  ((word.synonyms != nil && [word.synonyms count] > 0) || (word.paranyms!= nil && [word.paranyms count] > 0) || (word.antonyms != nil && [word.antonyms count] > 0)) {
            
            [self.ShowMoreBtn setEnabled:YES];
            [self.ShowMoreBtn setHidden:NO];
            self.ShowMoreBtn.alpha = 0;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5f];
            self.ShowMoreBtn.alpha = 1;
            [UIView commitAnimations];
        }
        
        self.SameBtn.enabled = YES;
        self.AntonymBtn.enabled = YES;
        self.SynonymBtn.enabled = YES;
        
    }else if(_guessBtnState == YES)
    {       
        
        [self showTransSign];

//        [UIView beginAnimations:nil context:nil];
//        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//        [UIView setAnimationDelegate:self];
//        [UIView setAnimationDuration:0.2f];
//        
//        self.transGoLeft.alpha = 0.0f;
//        self.transGoRight.alpha = 0.0f;
//        [UIView commitAnimations];
        
        [self CoverDownToHiddenWord];
        if ((word.synonyms != nil && [word.synonyms count] > 0) || (word.paranyms!= nil && [word.paranyms count] > 0) || (word.antonyms != nil && [word.antonyms count] > 0)) {
            
            [self.ShowMoreBtn setEnabled:YES];
            [self.ShowMoreBtn setHidden:NO];
            self.ShowMoreBtn.alpha = 0;
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5f];
            self.ShowMoreBtn.alpha = 1;
            [UIView commitAnimations];
        }
        self.SameBtn.enabled = YES;
        self.AntonymBtn.enabled = YES;
        self.SynonymBtn.enabled = YES;
        
        _guessBtnState = NO;
        _guessBtnTouchCount++;
    }else if(_guessBtnState == NO)
    {
                
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDuration:0.2f];
        
        self.transGoLeft.alpha = 0.0f;
        self.transGoRight.alpha = 0.0f;
        [UIView commitAnimations];
        
        
//                [UIView beginAnimations:nil context:nil];
//                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//                [UIView setAnimationDelegate:self];
//                [UIView setAnimationDuration:0.2f];
//                
//                self.transGoLeft.alpha = 0.0f;
//               self.transGoRight.alpha = 0.0f;
//                [UIView commitAnimations];

        [self CoverUpToShowWord];
        [self HiddenThreeImgView];
        
        //同义词，近义词，反义词同时翻过来
        if (_sameBtnState == YES) {
            [self ViewFlipToHiddenWord:self.SameImgView];
            [self ViewFlipToHiddenWord:self.SameShadowImgView];
            //[self ButtonMoveToMiddle:self.SameBtn];
            _sameBtnState = NO;

        }
        if (_antonymBtnState == YES) {
            [self ViewFlipToHiddenWord:self.AntonymImgView];
            [self ViewFlipToHiddenWord:self.AntonymShadowImgView];
            //[self ButtonMoveToMiddle:self.AntonymBtn];
            _antonymBtnState = NO;
        }
        if (_synonymBtnState == YES) {
            [self ViewFlipToHiddenWord:self.SynonymImgView];
           
            //9.16gengxin
             [self ViewFlipToHiddenWord:self.SynonymShadowImgView];
            
//            [self ViewFlipToShowWord:self.SynonymShadowImgView];
           // [self ButtonMoveToMiddle:self.SynonymBtn];
            _synonymBtnState = NO;
        }
        
//        self.SameBtn.enabled = NO;
//        self.AntonymBtn.enabled = NO;
//        self.SynonymBtn.enabled = NO;
        
        _guessBtnState = YES;
        _guessBtnTouchCount++;
    }
}

- (IBAction)SameWordAnimation:(id)sender {
    
        if (_sameBtnState == YES) {
            [self ViewFlipToHiddenWord:self.SameImgView];
            [self ViewFlipToHiddenWord:self.SameShadowImgView];
            [self ButtonMoveToMiddle:self.SameBtn];
            
            _sameBtnState = NO;
        }else {
            [self ViewFlipToShowWord:self.SameImgView];
            [self ViewFlipToShowWord:self.SameShadowImgView];
            [self ButtonMoveToLeft:self.SameBtn];
            
            _sameBtnState = YES;
        }
}

- (IBAction)AntonymWordAnimation:(id)sender {

        if (_antonymBtnState == YES) {
            [self ViewFlipToHiddenWord:self.AntonymImgView];
            [self ViewFlipToHiddenWord:self.AntonymShadowImgView];
            [self ButtonMoveToMiddle:self.AntonymBtn];
            
            _antonymBtnState = NO;
        }else {
            [self ViewFlipToShowWord:self.AntonymImgView];
            [self ViewFlipToShowWord:self.AntonymShadowImgView];
            [self ButtonMoveToLeft:self.AntonymBtn];
            
            _antonymBtnState = YES;
        }
}

- (IBAction)SynonymWordAnimation:(id)sender {

        if (_synonymBtnState == YES) {
            [self ViewFlipToHiddenWord:self.SynonymImgView];
            [self ViewFlipToHiddenWord:self.SynonymShadowImgView];
            [self ButtonMoveToMiddle:self.SynonymBtn];
            _synonymBtnState = NO;
        }else {
            [self ViewFlipToShowWord:self.SynonymImgView];
            [self ViewFlipToShowWord:self.SynonymShadowImgView];
            [self ButtonMoveToLeft:self.SynonymBtn];
            
            _synonymBtnState = YES;
        }
}

//查看单词动作
- (void)CoverUpToShowWord
{
    self.wordIndexLabel.alpha = 0;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.4f];
    [UIView setAnimationDelegate:self];
    [self.TopBackImgView exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
    self.TopBackImgView.frame = CGRectMake(11, 13, 297, 156);
    self.wordIndexLabel.alpha = 1;
    self.GuessBtn.frame = CGRectMake(137, 150, 44, 44);
    [UIView setAnimationDidStopSelector:@selector(enableGuessBtn)];
    [UIView commitAnimations];
}
//遮住刷新单词动作
-(void)enableGuessBtn
{

    GuessBtn.enabled=YES;

}

- (void)CoverDownToHiddenWord
{
    self.wordIndexLabel.alpha = 1;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.4f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatAutoreverses:NO];
    [self.TopBackImgView exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
    self.TopBackImgView.frame = CGRectMake(11, 43, 297, 156);
    self.wordIndexLabel.alpha = 0;
    self.GuessBtn.frame = CGRectMake(137, 178, 44, 44);
    [UIView setAnimationDidStopSelector:@selector(enableGuessBtn)];
    [UIView commitAnimations];
}
//翻转显示单词

-(void)showTransSign
{

    //9.15 gengxin
            NSInteger wordsCount = [word.tanses count];
            
            int currentIndex = translateScrollView.contentOffset.x/195 + 1;
            
            if (currentIndex > 1 && currentIndex < wordsCount) {
                
                
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
                
                self.transGoLeft.alpha = 1.0f;
                self.transGoRight.alpha = 1.0f;
                [UIView commitAnimations];
                
                
            }else if(currentIndex == 1 && wordsCount > 1){
                //            self.synonyLeftImgView.hidden = YES;
                //            self.synonyRightImgView.hidden = NO;
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
                
                self.transGoLeft.alpha = 0.0f;
                self.transGoRight.alpha = 1.0f;
                [UIView commitAnimations];
                
                
            }else if(currentIndex == wordsCount && wordsCount > 1){
                //            self.synonyLeftImgView.hidden = NO;
                //            self.synonyRightImgView.hidden = YES;
                
                [UIView beginAnimations:nil context:nil];
                [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                [UIView setAnimationDelegate:self];
                [UIView setAnimationDuration:0.4f];
                
                self.transGoLeft.alpha = 1.0f;
                self.transGoRight.alpha = 0.0f;
                [UIView commitAnimations];
                
            }



}

- (void)ViewFlipToHiddenWord:(UIView *)view
{
    
//    
//    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
//    Time_Count=Time_Count+1.0f;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:77]).enabled=NO;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:88]).enabled=NO;
//    
//    if(Clock_Count==0)
//    {
//        [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(enableToolBtn:) userInfo:nil repeats:YES];
//    }
    
    
    if (view.tag != 0) {
        
        willHideTag = view.tag;
    }
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationWillStartSelector:@selector(hideWordWillStart:finished:context:)];
    [UIView setAnimationRepeatAutoreverses:NO];
    [view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
    [view setAlpha:0];
    [view setAlpha:1];
    
    [UIView commitAnimations];
    
    UIImageView *imgView = (UIImageView *)view;
    CATransition *animation = [CATransition animation];
    animation.delegate = view;
    animation.duration = 0.6f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;
    animation.type = @"oglFlip";
    if (imgView == self.SameShadowImgView || imgView == self.AntonymShadowImgView || imgView == self.SynonymShadowImgView) {
        [imgView setImage:[UIImage imageNamed:@"Learn_shadow.png"]];
    }else {
        [imgView setImage:[UIImage imageNamed:@"Learn_common.png"]];

    }
    
    
    [view.layer addAnimation:animation forKey:@"animation"];
}

-(void)hideWordWillStart:(NSString *)animationID finished:(BOOL)finished context:(void *)context 
{
    
    
//    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:77]).enabled=YES;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:88]).enabled=YES;
    
    NSInteger tag = willHideTag;
    switch (tag) {
        case 290:
            [paranyScrollView removeFromSuperview];
            self.sameLabel.alpha = 0.0f;
            self.sameLeftImgview.alpha = 0.0f;
            self.sameRightImgView.alpha = 0.0f;
            
            break;
            
        case 291:
            [synonyScrollView removeFromSuperview];
            self.synonyLabel.alpha = 0.0f;
            self.synonyLeftImgView.alpha = 0.0f;
            self.synonyRightImgView.alpha = 0.0f;
            
            break;
            
        case 292:
            [antonyScrollView removeFromSuperview];
            self.antonyLabel.alpha = 0.0f;
            self.antonyLeftImgView.alpha = 0.0f;
            self.antonyRightImgView.alpha = 0.0f;
            
            break;
            
        default:
            break;
    }
}

-(void)enableToolBtn:(NSTimer *)timer
{   Clock_Count=Clock_Count+0.1;
    //// NSLog(@"%d%d",Clock_Count,Time_Count);
    if(Clock_Count>=Time_Count)
    {   
        HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
        ((UIButton *)[appDelegate.MainToolBar viewWithTag:77]).enabled=YES;
        ((UIButton *)[appDelegate.MainToolBar viewWithTag:88]).enabled=YES;
        Time_Count=0.0f;
        Clock_Count=0.0f;
        [timer invalidate];
    
    }


}
//翻转隐藏单词
- (void)ViewFlipToShowWord:(UIView *)view
{
    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    Time_Count=Time_Count+1.0f;
    ((UIButton *)[appDelegate.MainToolBar viewWithTag:77]).enabled=NO;
     ((UIButton *)[appDelegate.MainToolBar viewWithTag:88]).enabled=NO;
    
    if(Clock_Count==0)
    {
    [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(enableToolBtn:) userInfo:nil repeats:YES];
    }
    [UIView beginAnimations:nil context:view];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(showWordDidStop:finished:context:)];
    [UIView setAnimationRepeatAutoreverses:NO];
    [view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
    [view setAlpha:0];
    [view setAlpha:1];
    [UIView commitAnimations];
    
    UIImageView *imgView = (UIImageView *)view;
    CATransition *animation = [CATransition animation];
    animation.delegate = view;
    animation.duration = 0.6f;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;
    animation.type = @"oglFlip";
    if (imgView == self.SameShadowImgView || imgView == self.AntonymShadowImgView || imgView == self.SynonymShadowImgView) {
        [imgView setImage:[UIImage imageNamed:@"Learn_shadow.png"]];
    }else {
        [imgView setImage:[UIImage imageNamed:@"Learn_show.png"]];

    }
    [view.layer addAnimation:animation forKey:@"animation"];
}

-(void)showWordDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context 
{
    UIView *view = (UIView *)context;
    NSInteger tag = view.tag;
    
       
    
//    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:77]).enabled=YES;
//    ((UIButton *)[appDelegate.MainToolBar viewWithTag:88]).enabled=YES;
    
//    [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(enabelToolBtn) userInfo:nil repeats:YES];
    

    switch (tag) {
        case 290:
            if (word.paranyms != nil && [word.paranyms count] > 0) {
                //2011.9.6 update
                paranyScrollView.frame = CGRectMake(107, 237, 195, 49);
                paranyScrollView.showsHorizontalScrollIndicator = NO;
                [paranyScrollView setDelegate:self];
                [paranyScrollView setTag:880];
                [paranyScrollView setPagingEnabled:YES];
                [self.view addSubview:paranyScrollView];
                if ([word.paranyms count] > 1) {
                    
                    self.sameLeftImgview.alpha = 0.0f;
                    self.sameRightImgView.alpha = 1.0f;
                }else {
                    self.sameLeftImgview.alpha = 0.0f;
                    self.sameRightImgView.alpha = 0.0f;
                }
                
                for (UIView *view in [paranyScrollView subviews]) {
                    [view removeFromSuperview];
                }
                
                for (int i = 0; i < [word.paranyms count]; i++) {
                    WordCommonView *commonView = [[[NSBundle mainBundle]loadNibNamed:@"WordCommonView" owner:self options:nil]objectAtIndex:0];
                    [commonView setBackgroundColor:[UIColor clearColor]];
                    [commonView setFrame:CGRectMake(195*i, 0, 195, 49)];
                    [commonView setContent:[word.paranyms objectAtIndex:i]];

                    // NSLog(@" THis is %@ ",[word.paranyms objectAtIndex:i]);
                    
                    [paranyScrollView addSubview:commonView];
                }
                [paranyScrollView setContentSize:CGSizeMake(195*[word.paranyms count], 49)];
            }
            
            self.sameLabel.alpha = 1.0f;
         break;
           
        case 291:
            if (word.synonyms != nil && [word.synonyms count] > 0) {
                //2011.9.6 update
                synonyScrollView.frame = CGRectMake(107,296, 195, 49);
                synonyScrollView.showsHorizontalScrollIndicator = NO;
                [synonyScrollView setDelegate:self];
                [synonyScrollView setTag:881];
                [synonyScrollView setPagingEnabled:YES];
                [self.view addSubview:synonyScrollView];
                if ([word.synonyms count] > 1) {
                    
                    self.synonyLeftImgView.alpha = 0.0f;
                    self.synonyRightImgView.alpha = 1.0f;
                }else {
                    self.synonyLeftImgView.alpha = 0.0f;
                    self.synonyRightImgView.alpha = 0.0f;
                }
                
                for (UIView *view in [synonyScrollView subviews]) {
                    [view removeFromSuperview];
                }
                
                
                for (int i = 0; i < [word.synonyms count]; i++) {
                    WordCommonView *commonView = [[[NSBundle mainBundle]loadNibNamed:@"WordCommonView" owner:self options:nil]objectAtIndex:0];
                    [commonView setBackgroundColor:[UIColor clearColor]];
                    [commonView setFrame:CGRectMake(195*i, 0, 195, 49)];
                    [commonView setContent:[word.synonyms objectAtIndex:i]];
                    
                    // NSLog(@"This is %@ ",[word.synonyms objectAtIndex:i]);
                    
                    [synonyScrollView addSubview:commonView];
                }
                [synonyScrollView setContentSize:CGSizeMake(195*[word.synonyms count], 49)];
            
            }
            
            self.synonyLabel.alpha = 1.0f;          
            break;
            
        case 292:
            if (word.antonyms != nil && [word.antonyms count] > 0) {
                //2011.9.6 update
                antonyScrollView.frame = CGRectMake(107,355, 195, 49);
                antonyScrollView.showsHorizontalScrollIndicator = NO;
                [antonyScrollView setDelegate:self];
                [antonyScrollView setTag:882];
                [antonyScrollView setPagingEnabled:YES];
                [self.view addSubview:antonyScrollView];
                if ([word.antonyms count] > 1) {
                    
                    self.antonyLeftImgView.alpha = 0.0f;
                    self.antonyRightImgView.alpha = 1.0f;
                }else {
                    self.antonyLeftImgView.alpha = 0.0f;
                    self.antonyRightImgView.alpha = 0.0f;
                }
                
                for (UIView *view in [antonyScrollView subviews]) {
                    [view removeFromSuperview];
                }
                
                for (int i = 0; i < [word.antonyms count]; i++) {
                    WordCommonView *commonView = [[[NSBundle mainBundle]loadNibNamed:@"WordCommonView" owner:self options:nil]objectAtIndex:0];
                    [commonView setBackgroundColor:[UIColor clearColor]];
                    [commonView setFrame:CGRectMake(195*i, 0, 195, 49)];
                    [commonView setContent:[word.antonyms objectAtIndex:i]];

                    [antonyScrollView addSubview:commonView];
                }
                [antonyScrollView setContentSize:CGSizeMake(195*[word.antonyms count], 49)];
            }
            
            self.antonyLabel.alpha = 1.0f;
            break;
            
        default:
            break;
    }
}

//按钮移动到左边显示单词
- (void)ButtonMoveToLeft:(id)sender
{
    UIButton *button = (UIButton *)sender;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.8f];
    [UIView setAnimationDelegate:self];
    if (button == self.SameBtn) {
        self.SameBtn.frame = CGRectMake(9, 237, 49, 49);
    }else if (button == self.AntonymBtn) {
        self.AntonymBtn.frame = CGRectMake(9, 296, 49, 49);

    }else if (button == self.SynonymBtn) {
        self.SynonymBtn.frame = CGRectMake(9, 355, 49, 49);

    }
    [button setAlpha:0];
    [button setAlpha:1];
    
    [UIView commitAnimations];
}
//按钮恢复到中间隐藏刷新单词
- (void)ButtonMoveToMiddle:(id)sender
{
    UIButton *button = (UIButton *)sender;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.8f];
    [UIView setAnimationDelegate:self];
    if (button == self.SameBtn) {
        self.SameBtn.frame = CGRectMake(135, 237, 49, 49);
        
    }else if (button == self.AntonymBtn) {
        self.AntonymBtn.frame = CGRectMake(135, 296, 49, 49);
        
    }else if (button == self.SynonymBtn) {
        self.SynonymBtn.frame = CGRectMake(135, 355, 49, 49);
        
    }
    [button setAlpha:0];
    [button setAlpha:1];
    

    [UIView commitAnimations];
}
//横幅出来后隐藏MoreBtn
//- (void)HiddenShowMoreBtn;
//{
//    self.ShowMoreBtn.hidden = YES;
//}
//将横幅推出到任意位置
- (void)PushImgView:(UIView *)view ToPosition:(CGRect)postion
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatAutoreverses:NO];
    [UIView setAnimationDidStopSelector:@selector(HiddenShowMoreBtn)];
    
    [view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
    [view setFrame:postion];
    
    [UIView commitAnimations];
}
//根据单词带得ID属性，找到单词是否拥有同义词，近义词，反义词，并准备好横幅
- (void)LoadPrepareThreeImgView
{
    CGRect FirstPostion = CGRectMake(0,600, 320, 44);
    CGRect FirstBtnPostion = CGRectMake(135, 600, 49, 49);
    CGRect FirstShadowPostion = CGRectMake(0, 600, 320, 111);
    
    //设置横条阴影背景
    [self.SameShadowImgView setFrame:FirstShadowPostion];
    [self.AntonymShadowImgView setFrame:FirstShadowPostion];
    [self.SynonymShadowImgView setFrame:FirstShadowPostion];
    [self.SameImgView setFrame:FirstPostion];
    [self.AntonymImgView setFrame:FirstPostion];
    [self.SynonymImgView setFrame:FirstPostion];
    
    [self.SameBtn setFrame:FirstBtnPostion];
    [self.AntonymBtn setFrame:FirstBtnPostion];
    [self.SynonymBtn setFrame:FirstBtnPostion];
    
    
    
    
}
//推出横幅 根据单词拥有哪几个种类相关推出几条横幅
- (void)ShowThreeImgView
{
    //定义三条横幅背景得位置
    if (word.paranyms && [word.paranyms count] > 0) {
        
        CGRect FirstPostion = CGRectMake(0, 237, 320, 49);
        CGRect FirstBtnPostion = CGRectMake(135, 237, 49, 49);
        CGRect FirstShadowPostion = CGRectMake(0, 240, 320, 111);
        
        [self PushImgView:self.SameImgView ToPosition:FirstPostion];
        [self PushImgView:self.SameBtn ToPosition:FirstBtnPostion];
        [self PushImgView:self.SameShadowImgView ToPosition:FirstShadowPostion];
    }
    if (word.synonyms && [word.synonyms count] > 0) {
        
        CGRect SecondPostion = CGRectMake(0, 296, 320, 49);
        CGRect SecondBtnPostion = CGRectMake(135, 296, 49, 49);
        CGRect SecondShadowPostion = CGRectMake(0, 299, 320, 111);
        
        [self PushImgView:self.AntonymImgView ToPosition:SecondPostion];
        [self PushImgView:self.AntonymBtn ToPosition:SecondBtnPostion];
        [self PushImgView:self.AntonymShadowImgView ToPosition:SecondShadowPostion];
    }
    
    if (word.antonyms && [word.antonyms count] > 0) {
        CGRect ThirdPostion = CGRectMake(0, 355, 320, 49);
        CGRect ThirdBtnPostion = CGRectMake(135, 355, 49, 49);
        CGRect ThirdShadowPostion = CGRectMake(0, 358, 320, 111);
        
        
        [self PushImgView:self.SynonymShadowImgView ToPosition:ThirdShadowPostion];
        [self PushImgView:self.SynonymImgView ToPosition:ThirdPostion];
        [self PushImgView:self.SynonymBtn ToPosition:ThirdBtnPostion];
        
    }
    
    //重设阴影
    [self.view addSubview:self.SynonymShadowImgView];
    [self.view addSubview:self.SynonymImgView];
    [self.view addSubview:self.AntonymShadowImgView];
    [self.view addSubview:self.AntonymImgView];
    [self.view addSubview:self.SameShadowImgView];
    [self.view addSubview:self.SameImgView];
    [self.view addSubview:self.sameLabel];
    [self.view addSubview:self.antonyLabel];
    [self.view addSubview:self.synonyLabel];
    [self.view addSubview:self.sameLeftImgview];
    [self.view addSubview:self.sameRightImgView];
    [self.view addSubview:self.antonyLeftImgView];
    [self.view addSubview:self.antonyRightImgView];
    [self.view addSubview:self.synonyLeftImgView];
    [self.view addSubview:self.synonyRightImgView];
    [self.view addSubview:self.SameBtn];
    [self.view addSubview:self.AntonymBtn];
    [self.view addSubview:self.SynonymBtn];
    
    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3f];
    [UIView setAnimationDelegate:self];
    [[appDelegate.MainToolBar viewWithTag:77]setAlpha:0.0f];
//    [[appDelegate.MainToolBar viewWithTag:88]setAlpha:1.0f];
    
    [UIView setAnimationDidStopSelector:@selector(showHideBtn)];
    [UIView commitAnimations];
  
    
    
}
-(void)showHideBtn
{HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3f];
    [UIView setAnimationDelegate:self];
   // [[appDelegate.MainToolBar viewWithTag:77]setAlpha:0.0f];
    [[appDelegate.MainToolBar viewWithTag:88]setAlpha:1.0f];
    
   
    [UIView commitAnimations];


}
//拉下隐藏横幅
- (void)HiddenThreeImgView
{
    
    [synonyScrollView removeFromSuperview];
    [paranyScrollView removeFromSuperview];
    [antonyScrollView removeFromSuperview];
    
    self.synonyLabel.alpha = 0.0f;
    self.antonyLabel.alpha = 0.0f;
    self.sameLabel.alpha = 0.0f;
    self.sameLeftImgview.alpha = 0.0f;
    self.sameRightImgView.alpha = 0.0f;
    self.synonyLeftImgView.alpha = 0.0f;
    self.synonyRightImgView.alpha = 0.0f;
    self.antonyLeftImgView.alpha = 0.0f;
    self.antonyRightImgView.alpha = 0.0f;
    
    
    CGRect FirstPostion = CGRectMake(0,600, 320, 49);
    CGRect FirstBtnPostion = CGRectMake(135, 600, 49, 49);
    CGRect FirstShadowPostion = CGRectMake(0, 600, 320, 111);
    
    [self PushImgView:self.SameImgView ToPosition:FirstPostion];
    [self PushImgView:self.SameBtn ToPosition:FirstBtnPostion];
    [self PushImgView:self.SameShadowImgView ToPosition:FirstShadowPostion];
    [self ViewFlipToHiddenWord:self.SameImgView];
    _sameBtnState = NO;
    
    [self PushImgView:self.AntonymImgView ToPosition:FirstPostion];
    [self PushImgView:self.AntonymBtn ToPosition:FirstBtnPostion];
    [self PushImgView:self.AntonymShadowImgView ToPosition:FirstShadowPostion];
    [self ViewFlipToHiddenWord:self.AntonymImgView];
    _antonymBtnState = NO;
    
    [self PushImgView:self.SynonymShadowImgView ToPosition:FirstShadowPostion];
    [self PushImgView:self.SynonymImgView ToPosition:FirstPostion];
    [self PushImgView:self.SynonymBtn ToPosition:FirstBtnPostion];
    [self ViewFlipToHiddenWord:self.SynonymImgView];
    _synonymBtnState = NO;
    
    
    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3f];
  
    [UIView setAnimationDelegate:self];
    //[[appDelegate.MainToolBar viewWithTag:77]setAlpha:1.0f];
    [[appDelegate.MainToolBar viewWithTag:88]setAlpha:0.0f];
    [UIView setAnimationDidStopSelector:@selector(removeThreeScroll)];
    [UIView commitAnimations];
    
    
    
    
    

    

   
}


-(void)removeThreeScroll
{
    [paranyScrollView removeFromSuperview];
    [synonyScrollView removeFromSuperview];
    [antonyScrollView removeFromSuperview];
    
    HotWordAppDelegate *appDelegate= (HotWordAppDelegate *)[UIApplication sharedApplication].delegate;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.3f];
    
    [UIView setAnimationDelegate:self];
    [[appDelegate.MainToolBar viewWithTag:77]setAlpha:1.0f];
    //[[appDelegate.MainToolBar viewWithTag:88]setAlpha:0.0f];
   
    [UIView commitAnimations];

    
    


}

//获取新单词
- (void)loadNewWord
{
    
}

- (IBAction)ReturnToMenu:(id)sender
{
    [[CacheData sharedData] syncLetterStatus];
    //[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)loadWordWhileCoverUp:(NSString *)wordID
{
    
}

- (void)saveCurrentWordIndex
{
}

@end
